#ifndef ITEM_H
#define ITEM_H

#include <iostream>
#include <string>
#include <vector>
#include <list>
#include "rule.h"

using namespace std;

class item : public rule {
  
  friend class parser;

 private:
  unsigned int Index;
  unsigned int Rang;
  vector<string> SonsSpan;
  string SonsSpanStr;
  string Span;
  bool Seen;

 public:
  //
 item (string lhs, vector<string> rhs, class features *sem, int index, int rang) : rule(lhs, rhs, sem)
    {
      Index=index;
      Rang=rang;
      Seen=false;
    }
  
  
  //
  unsigned int getIndex(){return Index;};
  unsigned int getRang(){return Rang;};
  void print(ostream&);
  bool finished();

  // compare deux items
  struct cmpitem {
    int operator() (item *i1, item *i2) 
    {
      if (i1->Id < i2->Id)
	return 0;
      else if (i1->Id > i2->Id)
	return 1;
      else if (i1->Index < i2->Index)
	return 0;
      else if (i1->Index > i2->Index)
	return 1;
      else if (i1->Rang < i2->Rang)
	return 0;
      else if (i1->Rang > i2->Rang)
	return 1;
      else if (i1->SonsSpanStr < i2->SonsSpanStr)
	return 0;
      else if (i1->SonsSpanStr > i2->SonsSpanStr)
	return 1;
      return 0;
    }
  };
  
};
// le type d'un ensemble d'items
typedef set <item *, item::cmpitem> ITEMSET;


#endif // ITEM_H
